/**
 * 路由拦截器
 */
import router from '../router/index';
import { userStoreHook } from '../store/modules/user'


router.beforeEach((to, from, next) => {
    const userStore = userStoreHook();
    const userInfo = userStore.userInfo;
    if(to.path === '/login') {
        next()
    }
    if(userInfo.isLogin){
        if(to.path === '/login'){
            next({ path: '/login' });
        }else {
            next();
        }
    }else {
        next({ path: '/login' });
    }
});